/**
 * Copyright (c) 2016,http://www.365wuliu.com/  All Rights Reserved.
 */
package com.cargo.base.utils;

import org.apache.poi.ss.usermodel.Cell;

import java.io.File;
import java.io.FileOutputStream;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;


/** 
 * test:一句话描述该类的作用
 * @Project Name:cargo 
 * @File Name:test.java 
 * @Package Name:com.cargo.utils
 * @Creator:wizard
 * @Date:2016年5月31日上午10:30:04 
 */

public class SysUtil {
	
	
	 public static void main(String[] args)
	    {
	        Calendar calendar = Calendar.getInstance();
	        Date date = new Date(System.currentTimeMillis());
	        calendar.setTime(date);
//	        calendar.add(Calendar.WEEK_OF_YEAR, -1);
	        calendar.add(Calendar.YEAR, 1);
	        date = calendar.getTime();
	        System.out.println(date);
	    }
	
	
	public static String getValue(Cell xssfRow) {
		if(xssfRow == null){
			return "";
		}
		if (xssfRow.getCellType() == xssfRow.CELL_TYPE_BOOLEAN) {
			return String.valueOf(xssfRow.getBooleanCellValue());
		} else if (xssfRow.getCellType() == xssfRow.CELL_TYPE_NUMERIC) {
			return String.valueOf(xssfRow.getNumericCellValue());
		} else {
			return String.valueOf(xssfRow.getStringCellValue());
		}
	}
	
	
	/**
	 * 判断是否为中文字符
	 * @param value
	 * @return
	 */
	public static boolean isChineseChar(String str){
	       boolean temp = false;
	       Pattern p=Pattern.compile("[\u4e00-\u9fa5]"); 
	       Matcher m=p.matcher(str); 
	       if(m.find()){ 
	           temp =  true;
	       }
	       return temp;
	   }
	
	
	
	/**
	 * 判断是否为英文字符
	 * @param value
	 * @return
	 */
	public static boolean ji(String s) {
		 boolean temp = false;
	       Pattern p=Pattern.compile("[/^[A-Za-z]+$/]"); 
	       Matcher m=p.matcher(s); 
	       if(m.find()){ 
	           temp =  true;
	       }
	       return temp;
	}
	
	
	/**
	 * 判断是否为数字
	 * @param value
	 * @return
	 */
	public static boolean isInteger(String value) {
		try {
			Integer.parseInt(value);
			return true;
		} catch (NumberFormatException e) {
			return false;
		}
	}
	
	
	public static void write(String path, List<String> wenjian){
		
		FileOutputStream out = null;    

        try {   

            out = new FileOutputStream(new File(path));   


            for (int i = 0; i < wenjian.size(); i++) {   

                out.write(wenjian.get(i).getBytes());   

            }   

            out.close();   


	}catch (Exception e) {
		e.printStackTrace();
	}
}

}
